﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Org.BouncyCastle;

namespace ConsoloWin.model
{
    public class OnrRun
    {

        public static string url = "https://sql.hz.gov.cn/ESBWeb/servlets/33.1111.zjhz.smzx.cgjparkingInfo.SynReq@1.0";
        public static string privateKey = "MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAKLQgp07slkmHn/NrfvsaGrzI/TsiJ2KhXtQ9eNofWmX/NyJFROVCORfILRCL5e1qS+aFcuYg/jekQxBwOpDMxEStIy+RKySPms6VOS/abEZ1UKsxK8deLrNqoiwITL9uiKsOmTp2ULZ76ntwrKVxxmPQr6wlu3F7L8DyyE1SnoHAgMBAAECgYEAm2JH5WtdsLsyjGJtU2qx1LArdspvL3tOHPyNTvUgC7CkAI1Lch7gF6O6AI7SAQW8a9OwTVhHSzKOV5ZBWNG9X12kzWinHQbxiItFdWTvlCBziS/fGbzIyO+O6HmtTCFdIBz0PBy30q9UDaHdwB3kCd+VDLabWKsaM8A0KTUxmFECQQDXvj08NLG0x/kpGnH9GzhDu7H5UH5Ich2McO4h+EGq/s+dBX1aWfkLlRZgWV1ltOpe0Zz47ZLTKu8APygqQnNFAkEAwTHw690v8VX/m5I/kgvVdeQ3/fQIYKTI6tjk/Ozf8Q9KRojD9snCMUc+z760UYbHNE9jTgu8vokBr0fcF4lG2wJAVEN0bVhzdBWK5pfyn5YLEsFzkNn0iN0xV1IgYFozY9MkScMEI87ya6iuVbFxvjC8PY6HTd6Usy+Yq7L/QAo2NQJABk10yJ0MpVji39ZjkIYmTpRFZ1mAtHZrv42X2tB3dcvD5o0rp29pkGX8nJZiF47IDOLSIIetfqHFlkxH19S4pQJAINvZg5QNNSnjWYUr/S50CJXaEoG/zVfObpcP71R9qdAGvZYkuqFedzeG6kWHgUVyHgw46fhMNRITKMr4MBifkw==";

        /// <summary>
        /// 
        /// </summary>
        public static void Runtime() 
        {
           
        }

        /// <summary>
        /// 
        /// </summary>
        public static void TwoRunTime() 
        {

        }

        private static readonly string hexChars = "0123456789ABCDEF";
        /// <summary>
        /// Bytes数组转为16进制
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public static string byteArray2HexString(byte[] data)
        {
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < data.Length; i++)
            {
                byte lo = (byte)(0xF & data[i]);
                byte hi = (byte)((int)((uint)(0xF0 & data[i]) >> 4));
                sb.Append(hexChars.Substring(hi, 1)).Append(hexChars.Substring(lo, 1));
            }
            return sb.ToString();
        }
        /// <summary>
        /// 16进制转为Bytes数组
        /// </summary>
        /// <param name="hexStr"></param>
        /// <returns></returns>
        public static byte[] hexString2ByteArray(String hexStr)
        {
            if (hexStr.Length % 2 != 0)
            {
                return null;
            }
            byte[] data = new byte[hexStr.Length / 2];
            for (int i = 0; i < hexStr.Length / 2; i++)
            {
                char hc = hexStr.Substring(2 * i, 1).ToCharArray()[0];//.charAt(2 * i);
                char lc = hexStr.Substring(2 * i + 1, 1).ToCharArray()[0];//.charAt(2 * i + 1);
                byte hb = hexChar2Byte(hc);
                byte lb = hexChar2Byte(lc);
                if ((hb < 0) || (lb < 0))
                {
                    return null;
                }
                int n = hb << 4;
                data[i] = ((byte)(n + lb));
            }
            return data;
        }
        private static byte hexChar2Byte(char c)
        {
            if ((c >= '0') && (c <= '9'))
            {
                return (byte)(c - '0');
            }
            if ((c >= 'a') && (c <= 'f'))
            {
                return (byte)(c - 'a' + 10);
            }
            if ((c >= 'A') && (c <= 'F'))
            {
                return (byte)(c - 'A' + 10);
            }
            return 0;
        }
    }
}
